﻿Imports Microsoft.Crm.Outlook.Sdk
Imports System.Threading

Module Module1

    <MTAThread()> Sub Main()
        Dim oOutlookService As New CrmOutlookService
        While (Not oOutlookService.IsCrmClientLoaded)
            Console.WriteLine("CRM Client not loaded wait 5 seconds")
            Thread.Sleep(5000)
        End While
        Try
            While Not oOutlookService.State = ClientState.Online
                Console.WriteLine("CRM Client not online wait 5 seconds")
                Thread.Sleep(5000)
            End While
            Console.WriteLine("Perform Syncronisation")
            oOutlookService.Sync(OutlookSyncType.Outlook)
            Console.WriteLine("Perform Syncronisation done.")
        Catch ex As Exception
            Console.WriteLine(ex.Message)
        End Try
    End Sub
End Module
